<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
$dirs = scandir(dirname(__FILE__).'/../modules');
$modules = array();
foreach ($dirs as $name){
    if ($name[0] != '.')
        $modules[$name] = array('class'=>'application.modules.' . $name . '.' . ucfirst($name) . 'Module');
}
//var_dump($modules);

return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'Project 4',
    'sourceLanguage'=>'en',
    'language'      =>'ru',
	// preloading 'log' component
	'preload'=>array('log','config'),
    'theme'=>'metronic',
   // 'homeUrl'=>array('menu/index'),
    // autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
	),

	'modules'=>array_replace($modules,array(

        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'123',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters'=>array('127.0.0.1','::1'),
        ),
    )),

	// application components
	'components'=>array(

        //Кон-ия приложения хранятся в Config
        'config'=>array(
            'class'=>'Config',
            //'cache'=>3600,Пееред использванием надо настроить кеш
        ),
        //Security
        //'request'=>array(
        //    'enableCsrfValidation'=>true,
        //),
        //'request'=>array(
        //    'enableCookieValidation'=>true,
        //),
        'user'=>array(
            'loginUrl' => '/user/login',
            'allowAutoLogin'=>true,
            'class' => 'application.modules.user.components.WebUser',
        ),

		'urlManager'=>array(
			'urlFormat'=>'path',
            'showScriptName'=>false,
          //  'urlSuffix'=>'.jsp',
            'rules'=>array(
                'menu/<category:\w+>'=>'menu/frontend/main/category/<category>',
                '/user/login'=>'/user/frontend/login',
                '/user/registration'=>'/user/frontend/registration',
                '/user/registration/success'=>'/user/frontend/success',
                'user/activation'=>'/user/frontend/activation',
                '/user/activation/success'=>'/user/frontend/success',
                '/user/logout'=>'/user/frontend/logout',
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
				'<module:\w>/<controller:\w+>/<action:\w+>'=>'<module>/<controller>/<action>',
			),
		),

		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=project4_db',
			'emulatePrepare' => true,
            'tablePrefix'=>'tbl_',
			'username' => 'project4_user',
			'password' => '123',
			'charset' => 'utf8',
            'enableProfiling'=>true,
            'enableParamLogging' => true,
		),
        'authManager'=>array(
            'class'=>'CDbAuthManager',
            'connectionID'=>'db',
            'itemTable' =>'tbl_auth_item',
            'itemChildTable' =>'tbl_auth_item_child',
            'assignmentTable' =>'tbl_auth_assignment',
            'defaultRoles' => array('guest'),
        ),

		'errorHandler'=>array(
			// use 'site/error' action to display errors
			'errorAction'=>'site/error',
		),
		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',//CProfileLogRoute
					'levels'=>'error, warning',
				),
              /*  array(
                    'class'=>'CDbLogRoute',
                    'levels'=>'trace, info,error, warning',
                    'logTableName'=>'tbl_logs',
                    'connectionID'=>'db',
                    'autoCreateLogTable'=>false,
                    'filter'=>'CLogFilter',
                ),*/

				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
        'Brand'=>'Проект 4',
		// this is used in contact page


	),
);